<template>
  <div class="table-component">
    <div class="row-content">
      <div class="order-number">
        <div class="order-number-left">
          <div>订单编号：</div>
          <div>{{ orderDetails.orderNo }}</div>
          <div class="copy" @click="copyText">复制</div>
        </div>
      </div>
      <div class="order-details" style="margin-top: 56px">
        <div>
          <div class="order-details-title">车牌号</div>
          <div class="row">
            <div class="order-details-licensePlate">
              {{ orderDetails.licensePlate }}
            </div>
            <div class="licensePlate-type">（月卡）</div>
          </div>
        </div>
        <div>
          <div class="order-details-title">车辆类型</div>
          <div class="order-details-content2">
            {{
              orderDetails.carType == 1
                ? "大型车"
                : orderDetails.carType == 2
                ? "小型车"
                : orderDetails.carType == 3
                ? "新能源"
                : orderDetails.carType == 4
                ? "特殊车辆"
                : "-"
            }}
          </div>
        </div>
        <div>
          <div class="order-details-title">停车时长</div>
          <div class="order-details-content">{{ orderDetails.duration }}</div>
        </div>
        <div>
          <div class="order-details-title">泊位位置</div>
          <div class="order-details-content2">
            {{ orderDetails.section }}&nbsp;{{ orderDetails.berthCode }}
          </div>
        </div>
        <div>
          <div class="order-details-title">订单状态</div>
          <div class="order-details-status">
            <div class="order-number-right">
              <div class="icon-time">
                <img :src="iconTime" alt="" />
              </div>
              <div style="width: 100%">已完成</div>
            </div>
          </div>
        </div>
      </div>
      <div class="order-details" style="margin-top: 64px">
        <div>
          <div class="order-details-title">实付金额（元）</div>
          <div class="order-details-money">
            {{ orderDetails.received }}
          </div>
        </div>
        <!-- <div>
          <div class="order-details-title">待付金额（元）</div>
          <div class="order-details-money">
            {{ orderDetails.toBePaid }}
          </div>
        </div> -->
        <div>
          <div class="order-details-title">手机号</div>
          <div class="order-details-phone">{{ orderDetails.mebPhone }}</div>
        </div>
        <div>
          <div class="order-details-title">登记方式</div>
          <div class="row">
            <div class="order-details-content2">
              <div v-if="orderDetails.checkWay === 1">PDA</div>
              <div v-else-if="orderDetails.checkWay === 2">高位视频</div>
              <div v-else-if="orderDetails.checkWay === 3">视频桩</div>
              <div v-else-if="orderDetails.checkWay === 4">巡检车</div>
              <div v-else>-</div>
            </div>
            <div class="row iconPictures" @click="pictureData(orderDetails)">
              <img :src="iconPicture" alt="" class="icon-img" />
              <div>查看图片</div>
            </div>
          </div>
        </div>
        <div>
          <div class="order-details-title">登记收费员</div>
          <div class="order-details-content2">
            {{ orderDetails.inPdaUser }}
          </div>
        </div>
        <div></div>
      </div>

      <el-dialog
        v-model="dialogVisible"
        :title="title"
        destroy-on-close
        :before-close="handleClose"
        :close-on-click-modal="false"
        width="390"
      >
        <component
          :is="componentTag"
          @operationDone="operationDone"
          :data="operationId"
        >
        </component>
      </el-dialog>
    </div>
  </div>
</template>

<script setup>
import { ref, defineProps, shallowRef } from "vue";
import iconPicture from "@/assets/image/ico/orderManagements/icon-picture.png";
import iconTime from "@/assets/image/ico/orderManagements/times.png";
import pictureComponent from "./pictureComponent.vue";
const props = defineProps({
  orderDetails: {
    type: Object,
    default: () => {},
  },
});

// 弹窗
const title = ref("");
const dialogVisible = ref(false);
const componentTag = shallowRef("");
const operationId = ref("");
const operationDone = (r) => {
  dialogVisible.value = false;
  operationId.value = "";
  if (!r) {
    getData();
  }
};

const copyText = async () => {
  try {
    await navigator.clipboard.writeText(props.orderDetails.orderNo);
    alert("复制成功");
  } catch (err) {
    alert("复制失败", err);
  }
};

const pictureData = (row) => {
  title.value = "车辆照片";
  operationId.value = row;
  componentTag.value = pictureComponent;
  dialogVisible.value = true;
};
</script>

<style lang="less" scoped>
.table-component {
  .row-content {
    .order-number {
      display: flex;
      justify-content: space-between;
      align-items: center;
      // margin-bottom: 24px;
      .order-number-left {
        display: flex;
        align-items: center;
        font-weight: 600;
        font-size: 26px;
        color: #333333;
        .copy {
          background: #ffffff;
          border-radius: 2px;
          border: 1px solid #666666;
          font-weight: 500;
          font-size: 16px;
          color: #666666;
          text-align: center;
          width: 46px;
          line-height: 24px;
          margin-left: 12px;
          cursor: pointer;
        }
      }
    }
    .order-details {
      display: flex;
      .order-details-title {
        font-weight: 400;
        font-size: 18px;
        color: #666666;
        margin-bottom: 15px;
      }
      .order-details-status {
        display: flex;
        justify-content: center;
      }
      .order-details-licensePlate {
        background: url("../../../../../assets/image/ico/orderManagements/bg-license-plate.png")
          no-repeat;
        background-size: 100% 100%;
        width: 117px;
        height: 36px;
        line-height: 36px;
        text-align: center;
        font-weight: 500;
        font-size: 18px;
        color: #ffffff;
      }
      .licensePlate-type {
        font-weight: 600;
        font-size: 20px;
        color: #000000;
      }
      .order-details-content {
        font-weight: 600;
        font-size: 24px;
        color: #333333;
      }
      .order-details-money {
        font-weight: 600;
        font-size: 24px;
        color: #de2910;
      }

      .order-details-phone {
        font-weight: 600;
        font-size: 24px;
        color: #333333;
      }

      .order-details-content2 {
        font-weight: 400;
        font-size: 24px;
        color: #333333;
      }

      .order-number-right {
        width: 103px;
        display: flex;
        align-items: center;
        border: 1px solid #007aff;
        border-radius: 3px;
        background: #ffffff;
        font-weight: 500;
        font-size: 18px;
        color: #007aff;
        text-align: center;
        .icon-time {
          display: flex;
          background: #007aff;
          padding: 4px;
          img {
            width: 24px;
            height: 24px;
          }
        }
      }

      .iconPictures {
        background: #ebf2fb;
        border-radius: 2px;
        font-weight: 400;
        font-size: 14px;
        color: #007aff;
        width: 87px;
        height: 24px;
        text-align: center;
        padding: 2px 4px;
        margin-left: 11px;
        cursor: pointer;
      }

      span:first-child {
        font-weight: 400;
        font-size: 14px;
        color: #666666;
      }
      span:last-child {
        font-weight: 400;
        font-size: 14px;
        color: #1d2129;
      }
      .order-status {
        div:first-child {
          font-weight: 400;
          font-size: 14px;
          color: #666666;
        }
        div:last-child {
          font-weight: 600;
          font-size: 18px;
          color: #333333;
        }
      }
    }
    .order-details > div {
      flex: 1;
      text-align: center;
    }
    .order-money {
      margin-top: 24px;
      background: #f2f7fc;
      border-radius: 2px;
      padding: 24px;
      display: flex;
      > div {
        flex: 1;
        div:first-child {
          font-weight: 400;
          font-size: 14px;
          color: #666666;
          margin-bottom: 12px;
        }
        div:last-child {
          font-weight: 600;
          font-size: 16px;
          color: #333333;
        }
      }
    }
  }
  .row {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .icon-img {
    width: 18px;
    height: 17px;
    cursor: pointer;
  }
}
</style>